package com.magenta.maxoptra.gis.format;

import com.magenta.maxoptra.gis.PostalCode;
import com.magenta.maxoptra.gis.format.postal.ParsePostalCodeException;

/**
 * @author Sergey Grachev
 */
public interface PostalCodeFormat {

    /**
     * Parse of the postal code using the internal rules. For example different postal codes for countries
     *
     * @param postalCode for parsing
     * @param flags      additional options for parsing ({@link PostalCodeFormatter})
     * @return new instance of postal code
     * @throws ParsePostalCodeException if format is incorrect
     */
    PostalCode parse(String postalCode, int flags) throws ParsePostalCodeException;

    /**
     * See {@link PostalCodeFormat#parse(String, int)}
     */
    PostalCode parse(String postalCode) throws ParsePostalCodeException;

    /**
     * Represents postal code string
     *
     * @param postalCode early parsed postal code
     * @return postal code string
     */
    String format(PostalCode postalCode);
}
